package com.capgemini.diabeo.service;

import java.util.ArrayList;
import java.util.List;

import com.capgemini.diabeo.R;
import com.capgemini.diabeo.manager.MealStatus;
import com.capgemini.diabeo.model.Category;
import com.capgemini.diabeo.model.CategoryDao.Properties;
import com.googlecode.androidannotations.annotations.EBean;

import de.greenrobot.dao.query.QueryBuilder;

@EBean
public class CategoryService extends AbstractDatabaseService {

	public List<Category> retrieveCategoryByMeal(MealStatus meal) {
		QueryBuilder<Category> query = dbHelper.getCategoryDao().queryBuilder()
				.where(Properties.MealTime.eq(meal.getValue()));
		return query.list();
	}

	public List<Category> createCategory(int nb, MealStatus mealTime) {
		List<Category> categories = new ArrayList<Category>();
//		for (int i = 0; i < nb; i++) {
//			Category category = new Category();
//			category.setMealTime(mealTime.getValue());
//			category.setName("category" + i);
//			categories.add(category);
//		}
		
		
		Category category1 = new Category();
		category1.setMealTime(mealTime.getValue());
		category1.setName(context.getString(R.string.title_catogary_entree));
		categories.add(category1);
		
		Category category2 = new Category();
		category2.setMealTime(mealTime.getValue());
		category2.setName(context.getString(R.string.title_catogary_plats));
		categories.add(category2);
		
		
		Category category3 = new Category();
		category3.setMealTime(mealTime.getValue());
		category3.setName(context.getString(R.string.title_catogary_acommpagne));
		categories.add(category3);
		
		
		Category category4 = new Category();
		category4.setMealTime(mealTime.getValue());
		category4.setName(context.getString(R.string.title_catogary_restauration));
		categories.add(category4);
		
		Category category5 = new Category();
		category5.setMealTime(mealTime.getValue());
		category5.setName(context.getString(R.string.title_catogary_dessert));
		categories.add(category5);
		
		
		Category category6 = new Category();
		category6.setMealTime(mealTime.getValue());
		category6.setName(context.getString(R.string.title_catogary_pain));
		categories.add(category6);
		
		Category category7 = new Category();
		category7.setMealTime(mealTime.getValue());
		category7.setName(context.getString(R.string.title_catogary_boisson));
		categories.add(category7);
		
		Category category8 = new Category();
		category8.setMealTime(mealTime.getValue());
		category8.setName(context.getString(R.string.title_catogary_aperitif));
		categories.add(category8);
		
		dbHelper.getCategoryDao().insertInTx(categories);
		return categories;
	}
}
